import functools

# Verilog-like integer slicing
def _slice(i, x, y):
    return (i & ((1 << (y + 1)) - 1)) >> x

class Opcode:
    all_opcodes = set()
    def __init__(self, pat):
        self.mask  = int(pat[1:].replace('0', '1').replace('?', '0'), 2)
        self.match = int(pat[1:].replace('?', '0'), 2)
        self.all_opcodes.add(self)

    @functools.lru_cache(maxsize=4096)
    def matches(self, inst):
        return (inst & self.mask) == self.match

    @classmethod
    @functools.lru_cache(maxsize=4096)
    def decode(self, inst):
        for opcode in self.all_opcodes:
            if opcode.matches(inst):
                return opcode
        return None

class Instruction:
    def __init__(self, inst):
        self._opcode = None
        self.inst = inst

    @property
    def opcode(self):
        if not self._opcode:
            self._opcode = Opcode.decode(self.inst)
        return self._opcode

    def __getitem__(self, i):
        if isinstance(i, slice):
            assert(i.step is None)
            start = i.start
            stop = i.stop
            assert(start >= 0 and start < 32)
            assert(stop >= 0 and stop < 32 and stop > start)
            return (self.inst & ((1 << (stop + 1)) - 1)) >> start
        else:
            assert(i >= 0 and i < 32)
            return (self.inst >> i) & 1

# These are taken from Instructions.scala in rocket-chip
# Commentted out opcodes are not applicable for sodor
BEQ                = Opcode("b?????????????????000?????1100011")
BNE                = Opcode("b?????????????????001?????1100011")
BLT                = Opcode("b?????????????????100?????1100011")
BGE                = Opcode("b?????????????????101?????1100011")
BLTU               = Opcode("b?????????????????110?????1100011")
BGEU               = Opcode("b?????????????????111?????1100011")
JALR               = Opcode("b?????????????????000?????1100111")
JAL                = Opcode("b?????????????????????????1101111")
LUI                = Opcode("b?????????????????????????0110111")
AUIPC              = Opcode("b?????????????????????????0010111")
ADDI               = Opcode("b?????????????????000?????0010011")
SLLI               = Opcode("b000000???????????001?????0010011")
SLTI               = Opcode("b?????????????????010?????0010011")
SLTIU              = Opcode("b?????????????????011?????0010011")
XORI               = Opcode("b?????????????????100?????0010011")
SRLI               = Opcode("b000000???????????101?????0010011")
SRAI               = Opcode("b010000???????????101?????0010011")
ORI                = Opcode("b?????????????????110?????0010011")
ANDI               = Opcode("b?????????????????111?????0010011")
ADD                = Opcode("b0000000??????????000?????0110011")
SUB                = Opcode("b0100000??????????000?????0110011")
SLL                = Opcode("b0000000??????????001?????0110011")
SLT                = Opcode("b0000000??????????010?????0110011")
SLTU               = Opcode("b0000000??????????011?????0110011")
XOR                = Opcode("b0000000??????????100?????0110011")
SRL                = Opcode("b0000000??????????101?????0110011")
SRA                = Opcode("b0100000??????????101?????0110011")
OR                 = Opcode("b0000000??????????110?????0110011")
AND                = Opcode("b0000000??????????111?????0110011")
ADDIW              = Opcode("b?????????????????000?????0011011")
SLLIW              = Opcode("b0000000??????????001?????0011011")
SRLIW              = Opcode("b0000000??????????101?????0011011")
SRAIW              = Opcode("b0100000??????????101?????0011011")
ADDW               = Opcode("b0000000??????????000?????0111011")
SUBW               = Opcode("b0100000??????????000?????0111011")
SLLW               = Opcode("b0000000??????????001?????0111011")
SRLW               = Opcode("b0000000??????????101?????0111011")
SRAW               = Opcode("b0100000??????????101?????0111011")
LB                 = Opcode("b?????????????????000?????0000011")
LH                 = Opcode("b?????????????????001?????0000011")
LW                 = Opcode("b?????????????????010?????0000011")
LD                 = Opcode("b?????????????????011?????0000011")
LBU                = Opcode("b?????????????????100?????0000011")
LHU                = Opcode("b?????????????????101?????0000011")
LWU                = Opcode("b?????????????????110?????0000011")
SB                 = Opcode("b?????????????????000?????0100011")
SH                 = Opcode("b?????????????????001?????0100011")
SW                 = Opcode("b?????????????????010?????0100011")
SD                 = Opcode("b?????????????????011?????0100011")
FENCE              = Opcode("b?????????????????000?????0001111")
FENCE_I            = Opcode("b?????????????????001?????0001111")
MUL                = Opcode("b0000001??????????000?????0110011")
MULH               = Opcode("b0000001??????????001?????0110011")
MULHSU             = Opcode("b0000001??????????010?????0110011")
MULHU              = Opcode("b0000001??????????011?????0110011")
DIV                = Opcode("b0000001??????????100?????0110011")
DIVU               = Opcode("b0000001??????????101?????0110011")
REM                = Opcode("b0000001??????????110?????0110011")
REMU               = Opcode("b0000001??????????111?????0110011")
MULW               = Opcode("b0000001??????????000?????0111011")
DIVW               = Opcode("b0000001??????????100?????0111011")
DIVUW              = Opcode("b0000001??????????101?????0111011")
REMW               = Opcode("b0000001??????????110?????0111011")
REMUW              = Opcode("b0000001??????????111?????0111011")
# ANDN               = Opcode("b0100000??????????111?????0110011")
# ORN                = Opcode("b0100000??????????110?????0110011")
# XNOR               = Opcode("b0100000??????????100?????0110011")
# SLO                = Opcode("b0010000??????????001?????0110011")
# SRO                = Opcode("b0010000??????????101?????0110011")
# ROL                = Opcode("b0110000??????????001?????0110011")
# ROR                = Opcode("b0110000??????????101?????0110011")
# SBCLR              = Opcode("b0100100??????????001?????0110011")
# SBSET              = Opcode("b0010100??????????001?????0110011")
# SBINV              = Opcode("b0110100??????????001?????0110011")
# SBEXT              = Opcode("b0100100??????????101?????0110011")
# GORC               = Opcode("b0010100??????????101?????0110011")
# GREV               = Opcode("b0110100??????????101?????0110011")
# SLOI               = Opcode("b001000???????????001?????0010011")
# SROI               = Opcode("b001000???????????101?????0010011")
# RORI               = Opcode("b011000???????????101?????0010011")
# SBCLRI             = Opcode("b010010???????????001?????0010011")
# SBSETI             = Opcode("b001010???????????001?????0010011")
# SBINVI             = Opcode("b011010???????????001?????0010011")
# SBEXTI             = Opcode("b010010???????????101?????0010011")
# GORCI              = Opcode("b001010???????????101?????0010011")
# GREVI              = Opcode("b011010???????????101?????0010011")
# CMIX               = Opcode("b?????11??????????001?????0110011")
# CMOV               = Opcode("b?????11??????????101?????0110011")
# FSL                = Opcode("b?????10??????????001?????0110011")
# FSR                = Opcode("b?????10??????????101?????0110011")
# FSRI               = Opcode("b?????1???????????101?????0010011")
# CLZ                = Opcode("b011000000000?????001?????0010011")
# CTZ                = Opcode("b011000000001?????001?????0010011")
# PCNT               = Opcode("b011000000010?????001?????0010011")
# SEXT_B             = Opcode("b011000000100?????001?????0010011")
# SEXT_H             = Opcode("b011000000101?????001?????0010011")
# CRC32_B            = Opcode("b011000010000?????001?????0010011")
# CRC32_H            = Opcode("b011000010001?????001?????0010011")
# CRC32_W            = Opcode("b011000010010?????001?????0010011")
# CRC32C_B           = Opcode("b011000011000?????001?????0010011")
# CRC32C_H           = Opcode("b011000011001?????001?????0010011")
# CRC32C_W           = Opcode("b011000011010?????001?????0010011")
# SH1ADD             = Opcode("b0010000??????????010?????0110011")
# SH2ADD             = Opcode("b0010000??????????100?????0110011")
# SH3ADD             = Opcode("b0010000??????????110?????0110011")
# CLMUL              = Opcode("b0000101??????????001?????0110011")
# CLMULR             = Opcode("b0000101??????????010?????0110011")
# CLMULH             = Opcode("b0000101??????????011?????0110011")
# MIN                = Opcode("b0000101??????????100?????0110011")
# MINU               = Opcode("b0000101??????????101?????0110011")
# MAX                = Opcode("b0000101??????????110?????0110011")
# MAXU               = Opcode("b0000101??????????111?????0110011")
# SHFL               = Opcode("b0000100??????????001?????0110011")
# UNSHFL             = Opcode("b0000100??????????101?????0110011")
# BEXT               = Opcode("b0000100??????????110?????0110011")
# BDEP               = Opcode("b0100100??????????110?????0110011")
# PACK               = Opcode("b0000100??????????100?????0110011")
# ZEXT_H_RV32        = Opcode("b000010000000?????100?????0110011")
# PACKU              = Opcode("b0100100??????????100?????0110011")
# PACKH              = Opcode("b0000100??????????111?????0110011")
# BFP                = Opcode("b0100100??????????111?????0110011")
# SHFLI              = Opcode("b0000100??????????001?????0010011")
# UNSHFLI            = Opcode("b0000100??????????101?????0010011")
# REV_RV32           = Opcode("b011010011111?????101?????0010011")
# REV8_RV32          = Opcode("b011010011000?????101?????0010011")
# BMATFLIP           = Opcode("b011000000011?????001?????0010011")
# CRC32_D            = Opcode("b011000010011?????001?????0010011")
# CRC32C_D           = Opcode("b011000011011?????001?????0010011")
# BMATOR             = Opcode("b0000100??????????011?????0110011")
# BMATXOR            = Opcode("b0100100??????????011?????0110011")
# ADDIWU             = Opcode("b?????????????????100?????0011011")
# SLLIU_W            = Opcode("b000010???????????001?????0011011")
# ADDWU              = Opcode("b0000101??????????000?????0111011")
# SUBWU              = Opcode("b0100101??????????000?????0111011")
# ADDU_W             = Opcode("b0000100??????????000?????0111011")
# SLOW               = Opcode("b0010000??????????001?????0111011")
# SROW               = Opcode("b0010000??????????101?????0111011")
# ROLW               = Opcode("b0110000??????????001?????0111011")
# RORW               = Opcode("b0110000??????????101?????0111011")
# SBCLRW             = Opcode("b0100100??????????001?????0111011")
# SBSETW             = Opcode("b0010100??????????001?????0111011")
# SBINVW             = Opcode("b0110100??????????001?????0111011")
# SBEXTW             = Opcode("b0100100??????????101?????0111011")
# GORCW              = Opcode("b0010100??????????101?????0111011")
# GREVW              = Opcode("b0110100??????????101?????0111011")
# SLOIW              = Opcode("b0010000??????????001?????0011011")
# SROIW              = Opcode("b0010000??????????101?????0011011")
# RORIW              = Opcode("b0110000??????????101?????0011011")
# SBCLRIW            = Opcode("b0100100??????????001?????0011011")
# SBSETIW            = Opcode("b0010100??????????001?????0011011")
# SBINVIW            = Opcode("b0110100??????????001?????0011011")
# GORCIW             = Opcode("b0010100??????????101?????0011011")
# GREVIW             = Opcode("b0110100??????????101?????0011011")
# FSLW               = Opcode("b?????10??????????001?????0111011")
# FSRW               = Opcode("b?????10??????????101?????0111011")
# FSRIW              = Opcode("b?????10??????????101?????0011011")
# CLZW               = Opcode("b011000000000?????001?????0011011")
# CTZW               = Opcode("b011000000001?????001?????0011011")
# PCNTW              = Opcode("b011000000010?????001?????0011011")
# SH1ADDU_W          = Opcode("b0010000??????????010?????0111011")
# SH2ADDU_W          = Opcode("b0010000??????????100?????0111011")
# SH3ADDU_W          = Opcode("b0010000??????????110?????0111011")
# CLMULW             = Opcode("b0000101??????????001?????0111011")
# CLMULRW            = Opcode("b0000101??????????010?????0111011")
# CLMULHW            = Opcode("b0000101??????????011?????0111011")
# SHFLW              = Opcode("b0000100??????????001?????0111011")
# UNSHFLW            = Opcode("b0000100??????????101?????0111011")
# BEXTW              = Opcode("b0000100??????????110?????0111011")
# BDEPW              = Opcode("b0100100??????????110?????0111011")
# PACKW              = Opcode("b0000100??????????100?????0111011")
# ZEXT_H             = Opcode("b000010000000?????100?????0111011")
# PACKUW             = Opcode("b0100100??????????100?????0111011")
# BFPW               = Opcode("b0100100??????????111?????0111011")
# REV                = Opcode("b011010111111?????101?????0010011")
# REV8               = Opcode("b011010111000?????101?????0010011")
# ORC_B              = Opcode("b001010000111?????101?????0010011")
# AMOADD_W           = Opcode("b00000????????????010?????0101111")
# AMOXOR_W           = Opcode("b00100????????????010?????0101111")
# AMOOR_W            = Opcode("b01000????????????010?????0101111")
# AMOAND_W           = Opcode("b01100????????????010?????0101111")
# AMOMIN_W           = Opcode("b10000????????????010?????0101111")
# AMOMAX_W           = Opcode("b10100????????????010?????0101111")
# AMOMINU_W          = Opcode("b11000????????????010?????0101111")
# AMOMAXU_W          = Opcode("b11100????????????010?????0101111")
# AMOSWAP_W          = Opcode("b00001????????????010?????0101111")
LR_W               = Opcode("b00010??00000?????010?????0101111")
SC_W               = Opcode("b00011????????????010?????0101111")
# AMOADD_D           = Opcode("b00000????????????011?????0101111")
# AMOXOR_D           = Opcode("b00100????????????011?????0101111")
# AMOOR_D            = Opcode("b01000????????????011?????0101111")
# AMOAND_D           = Opcode("b01100????????????011?????0101111")
# AMOMIN_D           = Opcode("b10000????????????011?????0101111")
# AMOMAX_D           = Opcode("b10100????????????011?????0101111")
# AMOMINU_D          = Opcode("b11000????????????011?????0101111")
# AMOMAXU_D          = Opcode("b11100????????????011?????0101111")
# AMOSWAP_D          = Opcode("b00001????????????011?????0101111")
LR_D               = Opcode("b00010??00000?????011?????0101111")
SC_D               = Opcode("b00011????????????011?????0101111")
ECALL              = Opcode("b00000000000000000000000001110011")
EBREAK             = Opcode("b00000000000100000000000001110011")
URET               = Opcode("b00000000001000000000000001110011")
SRET               = Opcode("b00010000001000000000000001110011")
MRET               = Opcode("b00110000001000000000000001110011")
MNRET              = Opcode("b01110000001000000000000001110011")
DRET               = Opcode("b01111011001000000000000001110011")
SFENCE_VMA         = Opcode("b0001001??????????000000001110011")
WFI                = Opcode("b00010000010100000000000001110011")
# CEASE              = Opcode("b00110000010100000000000001110011")
# CFLUSH_D_L1        = Opcode("b111111000000?????000000001110011")
# CDISCARD_D_L1      = Opcode("b111111000010?????000000001110011")
CSRRW              = Opcode("b?????????????????001?????1110011")
CSRRS              = Opcode("b?????????????????010?????1110011")
CSRRC              = Opcode("b?????????????????011?????1110011")
CSRRWI             = Opcode("b?????????????????101?????1110011")
CSRRSI             = Opcode("b?????????????????110?????1110011")
CSRRCI             = Opcode("b?????????????????111?????1110011")
# HFENCE_VVMA        = Opcode("b0010001??????????000000001110011")
# HFENCE_GVMA        = Opcode("b0110001??????????000000001110011")
# FADD_S             = Opcode("b0000000??????????????????1010011")
# FSUB_S             = Opcode("b0000100??????????????????1010011")
# FMUL_S             = Opcode("b0001000??????????????????1010011")
# FDIV_S             = Opcode("b0001100??????????????????1010011")
# FSGNJ_S            = Opcode("b0010000??????????000?????1010011")
# FSGNJN_S           = Opcode("b0010000??????????001?????1010011")
# FSGNJX_S           = Opcode("b0010000??????????010?????1010011")
# FMIN_S             = Opcode("b0010100??????????000?????1010011")
# FMAX_S             = Opcode("b0010100??????????001?????1010011")
# FSQRT_S            = Opcode("b010110000000?????????????1010011")
# FADD_D             = Opcode("b0000001??????????????????1010011")
# FSUB_D             = Opcode("b0000101??????????????????1010011")
# FMUL_D             = Opcode("b0001001??????????????????1010011")
# FDIV_D             = Opcode("b0001101??????????????????1010011")
# FSGNJ_D            = Opcode("b0010001??????????000?????1010011")
# FSGNJN_D           = Opcode("b0010001??????????001?????1010011")
# FSGNJX_D           = Opcode("b0010001??????????010?????1010011")
# FMIN_D             = Opcode("b0010101??????????000?????1010011")
# FMAX_D             = Opcode("b0010101??????????001?????1010011")
# FCVT_S_D           = Opcode("b010000000001?????????????1010011")
# FCVT_D_S           = Opcode("b010000100000?????????????1010011")
# FSQRT_D            = Opcode("b010110100000?????????????1010011")
# FADD_Q             = Opcode("b0000011??????????????????1010011")
# FSUB_Q             = Opcode("b0000111??????????????????1010011")
# FMUL_Q             = Opcode("b0001011??????????????????1010011")
# FDIV_Q             = Opcode("b0001111??????????????????1010011")
# FSGNJ_Q            = Opcode("b0010011??????????000?????1010011")
# FSGNJN_Q           = Opcode("b0010011??????????001?????1010011")
# FSGNJX_Q           = Opcode("b0010011??????????010?????1010011")
# FMIN_Q             = Opcode("b0010111??????????000?????1010011")
# FMAX_Q             = Opcode("b0010111??????????001?????1010011")
# FCVT_S_Q           = Opcode("b010000000011?????????????1010011")
# FCVT_Q_S           = Opcode("b010001100000?????????????1010011")
# FCVT_D_Q           = Opcode("b010000100011?????????????1010011")
# FCVT_Q_D           = Opcode("b010001100001?????????????1010011")
# FSQRT_Q            = Opcode("b010111100000?????????????1010011")
# FLE_S              = Opcode("b1010000??????????000?????1010011")
# FLT_S              = Opcode("b1010000??????????001?????1010011")
# FEQ_S              = Opcode("b1010000??????????010?????1010011")
# FLE_D              = Opcode("b1010001??????????000?????1010011")
# FLT_D              = Opcode("b1010001??????????001?????1010011")
# FEQ_D              = Opcode("b1010001??????????010?????1010011")
# FLE_Q              = Opcode("b1010011??????????000?????1010011")
# FLT_Q              = Opcode("b1010011??????????001?????1010011")
# FEQ_Q              = Opcode("b1010011??????????010?????1010011")
# FCVT_W_S           = Opcode("b110000000000?????????????1010011")
# FCVT_WU_S          = Opcode("b110000000001?????????????1010011")
# FCVT_L_S           = Opcode("b110000000010?????????????1010011")
# FCVT_LU_S          = Opcode("b110000000011?????????????1010011")
# FMV_X_W            = Opcode("b111000000000?????000?????1010011")
# FCLASS_S           = Opcode("b111000000000?????001?????1010011")
# FCVT_W_D           = Opcode("b110000100000?????????????1010011")
# FCVT_WU_D          = Opcode("b110000100001?????????????1010011")
# FCVT_L_D           = Opcode("b110000100010?????????????1010011")
# FCVT_LU_D          = Opcode("b110000100011?????????????1010011")
# FMV_X_D            = Opcode("b111000100000?????000?????1010011")
# FCLASS_D           = Opcode("b111000100000?????001?????1010011")
# FCVT_W_Q           = Opcode("b110001100000?????????????1010011")
# FCVT_WU_Q          = Opcode("b110001100001?????????????1010011")
# FCVT_L_Q           = Opcode("b110001100010?????????????1010011")
# FCVT_LU_Q          = Opcode("b110001100011?????????????1010011")
# FMV_X_Q            = Opcode("b111001100000?????000?????1010011")
# FCLASS_Q           = Opcode("b111001100000?????001?????1010011")
# FCVT_S_W           = Opcode("b110100000000?????????????1010011")
# FCVT_S_WU          = Opcode("b110100000001?????????????1010011")
# FCVT_S_L           = Opcode("b110100000010?????????????1010011")
# FCVT_S_LU          = Opcode("b110100000011?????????????1010011")
# FMV_W_X            = Opcode("b111100000000?????000?????1010011")
# FCVT_D_W           = Opcode("b110100100000?????????????1010011")
# FCVT_D_WU          = Opcode("b110100100001?????????????1010011")
# FCVT_D_L           = Opcode("b110100100010?????????????1010011")
# FCVT_D_LU          = Opcode("b110100100011?????????????1010011")
# FMV_D_X            = Opcode("b111100100000?????000?????1010011")
# FCVT_Q_W           = Opcode("b110101100000?????????????1010011")
# FCVT_Q_WU          = Opcode("b110101100001?????????????1010011")
# FCVT_Q_L           = Opcode("b110101100010?????????????1010011")
# FCVT_Q_LU          = Opcode("b110101100011?????????????1010011")
# FMV_Q_X            = Opcode("b111101100000?????000?????1010011")
# FLW                = Opcode("b?????????????????010?????0000111")
# FLD                = Opcode("b?????????????????011?????0000111")
# FLQ                = Opcode("b?????????????????100?????0000111")
# FSW                = Opcode("b?????????????????010?????0100111")
# FSD                = Opcode("b?????????????????011?????0100111")
# FSQ                = Opcode("b?????????????????100?????0100111")
# FMADD_S            = Opcode("b?????00??????????????????1000011")
# FMSUB_S            = Opcode("b?????00??????????????????1000111")
# FNMSUB_S           = Opcode("b?????00??????????????????1001011")
# FNMADD_S           = Opcode("b?????00??????????????????1001111")
# FMADD_D            = Opcode("b?????01??????????????????1000011")
# FMSUB_D            = Opcode("b?????01??????????????????1000111")
# FNMSUB_D           = Opcode("b?????01??????????????????1001011")
# FNMADD_D           = Opcode("b?????01??????????????????1001111")
# FMADD_Q            = Opcode("b?????11??????????????????1000011")
# FMSUB_Q            = Opcode("b?????11??????????????????1000111")
# FNMSUB_Q           = Opcode("b?????11??????????????????1001011")
# FNMADD_Q           = Opcode("b?????11??????????????????1001111")
# FADD_H             = Opcode("b0000010??????????????????1010011")
# FSUB_H             = Opcode("b0000110??????????????????1010011")
# FMUL_H             = Opcode("b0001010??????????????????1010011")
# FDIV_H             = Opcode("b0001110??????????????????1010011")
# FSGNJ_H            = Opcode("b0010010??????????000?????1010011")
# FSGNJN_H           = Opcode("b0010010??????????001?????1010011")
# FSGNJX_H           = Opcode("b0010010??????????010?????1010011")
# FMIN_H             = Opcode("b0010110??????????000?????1010011")
# FMAX_H             = Opcode("b0010110??????????001?????1010011")
# FCVT_H_S           = Opcode("b010001000000?????????????1010011")
# FCVT_S_H           = Opcode("b010000000010?????????????1010011")
# FSQRT_H            = Opcode("b010111000000?????????????1010011")
# FLE_H              = Opcode("b1010010??????????000?????1010011")
# FLT_H              = Opcode("b1010010??????????001?????1010011")
# FEQ_H              = Opcode("b1010010??????????010?????1010011")
# FCVT_W_H           = Opcode("b110001000000?????????????1010011")
# FCVT_WU_H          = Opcode("b110001000001?????????????1010011")
# FMV_X_H            = Opcode("b111001000000?????000?????1010011")
# FCLASS_H           = Opcode("b111001000000?????001?????1010011")
# FCVT_H_W           = Opcode("b110101000000?????????????1010011")
# FCVT_H_WU          = Opcode("b110101000001?????????????1010011")
# FMV_H_X            = Opcode("b111101000000?????000?????1010011")
# FCVT_H_D           = Opcode("b010001000001?????????????1010011")
# FCVT_D_H           = Opcode("b010000100010?????????????1010011")
# FCVT_H_Q           = Opcode("b010001000011?????????????1010011")
# FCVT_Q_H           = Opcode("b010001100010?????????????1010011")
# FCVT_L_H           = Opcode("b110001000010?????????????1010011")
# FCVT_LU_H          = Opcode("b110001000011?????????????1010011")
# FCVT_H_L           = Opcode("b110101000010?????????????1010011")
# FCVT_H_LU          = Opcode("b110101000011?????????????1010011")
# FLH                = Opcode("b?????????????????001?????0000111")
# FSH                = Opcode("b?????????????????001?????0100111")
# FMADD_H            = Opcode("b?????10??????????????????1000011")
# FMSUB_H            = Opcode("b?????10??????????????????1000111")
# FNMSUB_H           = Opcode("b?????10??????????????????1001011")
# FNMADD_H           = Opcode("b?????10??????????????????1001111")
# C_ADDI4SPN         = Opcode("b????????????????000???????????00")
# C_FLD              = Opcode("b????????????????001???????????00")
# C_LW               = Opcode("b????????????????010???????????00")
# C_FLW              = Opcode("b????????????????011???????????00")
# C_FSD              = Opcode("b????????????????101???????????00")
# C_SW               = Opcode("b????????????????110???????????00")
# C_FSW              = Opcode("b????????????????111???????????00")
# C_ADDI             = Opcode("b????????????????000???????????01")
# C_JAL              = Opcode("b????????????????001???????????01")
# C_LI               = Opcode("b????????????????010???????????01")
# C_LUI              = Opcode("b????????????????011???????????01")
# C_SRLI             = Opcode("b????????????????100?00????????01")
# C_SRAI             = Opcode("b????????????????100?01????????01")
# C_ANDI             = Opcode("b????????????????100?10????????01")
# C_SUB              = Opcode("b????????????????100011???00???01")
# C_XOR              = Opcode("b????????????????100011???01???01")
# C_OR               = Opcode("b????????????????100011???10???01")
# C_AND              = Opcode("b????????????????100011???11???01")
# C_SUBW             = Opcode("b????????????????100111???00???01")
# C_ADDW             = Opcode("b????????????????100111???01???01")
# C_J                = Opcode("b????????????????101???????????01")
# C_BEQZ             = Opcode("b????????????????110???????????01")
# C_BNEZ             = Opcode("b????????????????111???????????01")
# C_SLLI             = Opcode("b????????????????000???????????10")
# C_FLDSP            = Opcode("b????????????????001???????????10")
# C_LWSP             = Opcode("b????????????????010???????????10")
# C_FLWSP            = Opcode("b????????????????011???????????10")
# C_MV               = Opcode("b????????????????1000??????????10")
# C_ADD              = Opcode("b????????????????1001??????????10")
# C_FSDSP            = Opcode("b????????????????101???????????10")
# C_SWSP             = Opcode("b????????????????110???????????10")
# C_FSWSP            = Opcode("b????????????????111???????????10")
# C_NOP              = Opcode("b????????????????0000000000000001")
# C_ADDI16SP         = Opcode("b????????????????011?00010?????01")
# C_JR               = Opcode("b????????????????1000?????0000010")
# C_JALR             = Opcode("b????????????????1001?????0000010")
# C_EBREAK           = Opcode("b????????????????1001000000000010")
# C_SRLI_RV32        = Opcode("b????????????????100000????????01")
# C_SRAI_RV32        = Opcode("b????????????????100001????????01")
# C_SLLI_RV32        = Opcode("b????????????????0000??????????10")
# C_LD               = Opcode("b????????????????011???????????00")
# C_SD               = Opcode("b????????????????111???????????00")
# C_ADDIW            = Opcode("b????????????????001???????????01")
# C_LDSP             = Opcode("b????????????????011???????????10")
# C_SDSP             = Opcode("b????????????????111???????????10")
# C_LQ               = Opcode("b????????????????001???????????00")
# C_SQ               = Opcode("b????????????????101???????????00")
# C_LQSP             = Opcode("b????????????????001???????????10")
# C_SQSP             = Opcode("b????????????????101???????????10")
CUSTOM0            = Opcode("b?????????????????000?????0001011")
CUSTOM0_RS1        = Opcode("b?????????????????010?????0001011")
CUSTOM0_RS1_RS2    = Opcode("b?????????????????011?????0001011")
CUSTOM0_RD         = Opcode("b?????????????????100?????0001011")
CUSTOM0_RD_RS1     = Opcode("b?????????????????110?????0001011")
CUSTOM0_RD_RS1_RS2 = Opcode("b?????????????????111?????0001011")
CUSTOM1            = Opcode("b?????????????????000?????0101011")
CUSTOM1_RS1        = Opcode("b?????????????????010?????0101011")
CUSTOM1_RS1_RS2    = Opcode("b?????????????????011?????0101011")
CUSTOM1_RD         = Opcode("b?????????????????100?????0101011")
CUSTOM1_RD_RS1     = Opcode("b?????????????????110?????0101011")
CUSTOM1_RD_RS1_RS2 = Opcode("b?????????????????111?????0101011")
CUSTOM2            = Opcode("b?????????????????000?????1011011")
CUSTOM2_RS1        = Opcode("b?????????????????010?????1011011")
CUSTOM2_RS1_RS2    = Opcode("b?????????????????011?????1011011")
CUSTOM2_RD         = Opcode("b?????????????????100?????1011011")
CUSTOM2_RD_RS1     = Opcode("b?????????????????110?????1011011")
CUSTOM2_RD_RS1_RS2 = Opcode("b?????????????????111?????1011011")
CUSTOM3            = Opcode("b?????????????????000?????1111011")
CUSTOM3_RS1        = Opcode("b?????????????????010?????1111011")
CUSTOM3_RS1_RS2    = Opcode("b?????????????????011?????1111011")
CUSTOM3_RD         = Opcode("b?????????????????100?????1111011")
CUSTOM3_RD_RS1     = Opcode("b?????????????????110?????1111011")
CUSTOM3_RD_RS1_RS2 = Opcode("b?????????????????111?????1111011")
# VSETVLI            = Opcode("b0????????????????111?????1010111")
# VSETVL             = Opcode("b1000000??????????111?????1010111")
# VLE8_V             = Opcode("b???000?00000?????000?????0000111")
# VLE16_V            = Opcode("b???000?00000?????101?????0000111")
# VLE32_V            = Opcode("b???000?00000?????110?????0000111")
# VLE64_V            = Opcode("b???000?00000?????111?????0000111")
# VSE8_V             = Opcode("b???000?00000?????000?????0100111")
# VSE16_V            = Opcode("b???000?00000?????101?????0100111")
# VSE32_V            = Opcode("b???000?00000?????110?????0100111")
# VSE64_V            = Opcode("b???000?00000?????111?????0100111")
# VLSE8_V            = Opcode("b???010???????????000?????0000111")
# VLSE16_V           = Opcode("b???010???????????101?????0000111")
# VLSE32_V           = Opcode("b???010???????????110?????0000111")
# VLSE64_V           = Opcode("b???010???????????111?????0000111")
# VSSE8_V            = Opcode("b???010???????????000?????0100111")
# VSSE16_V           = Opcode("b???010???????????101?????0100111")
# VSSE32_V           = Opcode("b???010???????????110?????0100111")
# VSSE64_V           = Opcode("b???010???????????111?????0100111")
# VLXEI8_V           = Opcode("b???011???????????000?????0000111")
# VLXEI16_V          = Opcode("b???011???????????101?????0000111")
# VLXEI32_V          = Opcode("b???011???????????110?????0000111")
# VLXEI64_V          = Opcode("b???011???????????111?????0000111")
# VSXEI8_V           = Opcode("b???011???????????000?????0100111")
# VSXEI16_V          = Opcode("b???011???????????101?????0100111")
# VSXEI32_V          = Opcode("b???011???????????110?????0100111")
# VSXEI64_V          = Opcode("b???011???????????111?????0100111")
# VSUXEI8_V          = Opcode("b000001???????????000?????0100111")
# VSUXEI16_V         = Opcode("b000001???????????101?????0100111")
# VSUXEI32_V         = Opcode("b000001???????????110?????0100111")
# VSUXEI64_V         = Opcode("b000001???????????111?????0100111")
# VLE8FF_V           = Opcode("b???000?10000?????000?????0000111")
# VLE16FF_V          = Opcode("b???000?10000?????101?????0000111")
# VLE32FF_V          = Opcode("b???000?10000?????110?????0000111")
# VLE64FF_V          = Opcode("b???000?10000?????111?????0000111")
# VL1RE8_V           = Opcode("b000000101000?????000?????0000111")
# VL1RE16_V          = Opcode("b000000101000?????101?????0000111")
# VL1RE32_V          = Opcode("b000000101000?????110?????0000111")
# VL1RE64_V          = Opcode("b000000101000?????111?????0000111")
# VL2RE8_V           = Opcode("b001000101000?????000?????0000111")
# VL2RE16_V          = Opcode("b001000101000?????101?????0000111")
# VL2RE32_V          = Opcode("b001000101000?????110?????0000111")
# VL2RE64_V          = Opcode("b001000101000?????111?????0000111")
# VL4RE8_V           = Opcode("b011000101000?????000?????0000111")
# VL4RE16_V          = Opcode("b011000101000?????101?????0000111")
# VL4RE32_V          = Opcode("b011000101000?????110?????0000111")
# VL4RE64_V          = Opcode("b011000101000?????111?????0000111")
# VL8RE8_V           = Opcode("b111000101000?????000?????0000111")
# VL8RE16_V          = Opcode("b111000101000?????101?????0000111")
# VL8RE32_V          = Opcode("b111000101000?????110?????0000111")
# VL8RE64_V          = Opcode("b111000101000?????111?????0000111")
# VS1R_V             = Opcode("b000000101000?????000?????0100111")
# VS2R_V             = Opcode("b001000101000?????000?????0100111")
# VS4R_V             = Opcode("b011000101000?????000?????0100111")
# VS8R_V             = Opcode("b111000101000?????000?????0100111")
# VFADD_VF           = Opcode("b000000???????????101?????1010111")
# VFSUB_VF           = Opcode("b000010???????????101?????1010111")
# VFMIN_VF           = Opcode("b000100???????????101?????1010111")
# VFMAX_VF           = Opcode("b000110???????????101?????1010111")
# VFSGNJ_VF          = Opcode("b001000???????????101?????1010111")
# VFSGNJN_VF         = Opcode("b001001???????????101?????1010111")
# VFSGNJX_VF         = Opcode("b001010???????????101?????1010111")
# VFSLIDE1UP_VF      = Opcode("b001110???????????101?????1010111")
# VFSLIDE1DOWN_VF    = Opcode("b001111???????????101?????1010111")
# VFMV_S_F           = Opcode("b010000100000?????101?????1010111")
# VFMERGE_VFM        = Opcode("b0101110??????????101?????1010111")
# VFMV_V_F           = Opcode("b010111100000?????101?????1010111")
# VMFEQ_VF           = Opcode("b011000???????????101?????1010111")
# VMFLE_VF           = Opcode("b011001???????????101?????1010111")
# VMFLT_VF           = Opcode("b011011???????????101?????1010111")
# VMFNE_VF           = Opcode("b011100???????????101?????1010111")
# VMFGT_VF           = Opcode("b011101???????????101?????1010111")
# VMFGE_VF           = Opcode("b011111???????????101?????1010111")
# VFDIV_VF           = Opcode("b100000???????????101?????1010111")
# VFRDIV_VF          = Opcode("b100001???????????101?????1010111")
# VFMUL_VF           = Opcode("b100100???????????101?????1010111")
# VFRSUB_VF          = Opcode("b100111???????????101?????1010111")
# VFMADD_VF          = Opcode("b101000???????????101?????1010111")
# VFNMADD_VF         = Opcode("b101001???????????101?????1010111")
# VFMSUB_VF          = Opcode("b101010???????????101?????1010111")
# VFNMSUB_VF         = Opcode("b101011???????????101?????1010111")
# VFMACC_VF          = Opcode("b101100???????????101?????1010111")
# VFNMACC_VF         = Opcode("b101101???????????101?????1010111")
# VFMSAC_VF          = Opcode("b101110???????????101?????1010111")
# VFNMSAC_VF         = Opcode("b101111???????????101?????1010111")
# VFWADD_VF          = Opcode("b110000???????????101?????1010111")
# VFWSUB_VF          = Opcode("b110010???????????101?????1010111")
# VFWADD_WF          = Opcode("b110100???????????101?????1010111")
# VFWSUB_WF          = Opcode("b110110???????????101?????1010111")
# VFWMUL_VF          = Opcode("b111000???????????101?????1010111")
# VFWMACC_VF         = Opcode("b111100???????????101?????1010111")
# VFWNMACC_VF        = Opcode("b111101???????????101?????1010111")
# VFWMSAC_VF         = Opcode("b111110???????????101?????1010111")
# VFWNMSAC_VF        = Opcode("b111111???????????101?????1010111")
# VFADD_VV           = Opcode("b000000???????????001?????1010111")
# VFREDSUM_VS        = Opcode("b000001???????????001?????1010111")
# VFSUB_VV           = Opcode("b000010???????????001?????1010111")
# VFREDOSUM_VS       = Opcode("b000011???????????001?????1010111")
# VFMIN_VV           = Opcode("b000100???????????001?????1010111")
# VFREDMIN_VS        = Opcode("b000101???????????001?????1010111")
# VFMAX_VV           = Opcode("b000110???????????001?????1010111")
# VFREDMAX_VS        = Opcode("b000111???????????001?????1010111")
# VFSGNJ_VV          = Opcode("b001000???????????001?????1010111")
# VFSGNJN_VV         = Opcode("b001001???????????001?????1010111")
# VFSGNJX_VV         = Opcode("b001010???????????001?????1010111")
# VFMV_F_S           = Opcode("b0100001?????00000001?????1010111")
# VMFEQ_VV           = Opcode("b011000???????????001?????1010111")
# VMFLE_VV           = Opcode("b011001???????????001?????1010111")
# VMFLT_VV           = Opcode("b011011???????????001?????1010111")
# VMFNE_VV           = Opcode("b011100???????????001?????1010111")
# VFDIV_VV           = Opcode("b100000???????????001?????1010111")
# VFMUL_VV           = Opcode("b100100???????????001?????1010111")
# VFMADD_VV          = Opcode("b101000???????????001?????1010111")
# VFNMADD_VV         = Opcode("b101001???????????001?????1010111")
# VFMSUB_VV          = Opcode("b101010???????????001?????1010111")
# VFNMSUB_VV         = Opcode("b101011???????????001?????1010111")
# VFMACC_VV          = Opcode("b101100???????????001?????1010111")
# VFNMACC_VV         = Opcode("b101101???????????001?????1010111")
# VFMSAC_VV          = Opcode("b101110???????????001?????1010111")
# VFNMSAC_VV         = Opcode("b101111???????????001?????1010111")
# VFCVT_XU_F_V       = Opcode("b010010??????00000001?????1010111")
# VFCVT_X_F_V        = Opcode("b010010??????00001001?????1010111")
# VFCVT_F_XU_V       = Opcode("b010010??????00010001?????1010111")
# VFCVT_F_X_V        = Opcode("b010010??????00011001?????1010111")
# VFCVT_RTZ_XU_F_V   = Opcode("b010010??????00110001?????1010111")
# VFCVT_RTZ_X_F_V    = Opcode("b010010??????00111001?????1010111")
# VFWCVT_XU_F_V      = Opcode("b010010??????01000001?????1010111")
# VFWCVT_X_F_V       = Opcode("b010010??????01001001?????1010111")
# VFWCVT_F_XU_V      = Opcode("b010010??????01010001?????1010111")
# VFWCVT_F_X_V       = Opcode("b010010??????01011001?????1010111")
# VFWCVT_F_F_V       = Opcode("b010010??????01100001?????1010111")
# VFWCVT_RTZ_XU_F_V  = Opcode("b010010??????01110001?????1010111")
# VFWCVT_RTZ_X_F_V   = Opcode("b010010??????01111001?????1010111")
# VFNCVT_XU_F_W      = Opcode("b010010??????10000001?????1010111")
# VFNCVT_X_F_W       = Opcode("b010010??????10001001?????1010111")
# VFNCVT_F_XU_W      = Opcode("b010010??????10010001?????1010111")
# VFNCVT_F_X_W       = Opcode("b010010??????10011001?????1010111")
# VFNCVT_F_F_W       = Opcode("b010010??????10100001?????1010111")
# VFNCVT_ROD_F_F_W   = Opcode("b010010??????10101001?????1010111")
# VFNCVT_RTZ_XU_F_W  = Opcode("b010010??????10110001?????1010111")
# VFNCVT_RTZ_X_F_W   = Opcode("b010010??????10111001?????1010111")
# VFSQRT_V           = Opcode("b010011??????00000001?????1010111")
# VFCLASS_V          = Opcode("b010011??????10000001?????1010111")
# VFWADD_VV          = Opcode("b110000???????????001?????1010111")
# VFWREDSUM_VS       = Opcode("b110001???????????001?????1010111")
# VFWSUB_VV          = Opcode("b110010???????????001?????1010111")
# VFWREDOSUM_VS      = Opcode("b110011???????????001?????1010111")
# VFWADD_WV          = Opcode("b110100???????????001?????1010111")
# VFWSUB_WV          = Opcode("b110110???????????001?????1010111")
# VFWMUL_VV          = Opcode("b111000???????????001?????1010111")
# VFDOT_VV           = Opcode("b111001???????????001?????1010111")
# VFWMACC_VV         = Opcode("b111100???????????001?????1010111")
# VFWNMACC_VV        = Opcode("b111101???????????001?????1010111")
# VFWMSAC_VV         = Opcode("b111110???????????001?????1010111")
# VFWNMSAC_VV        = Opcode("b111111???????????001?????1010111")
# VADD_VX            = Opcode("b000000???????????100?????1010111")
# VSUB_VX            = Opcode("b000010???????????100?????1010111")
# VRSUB_VX           = Opcode("b000011???????????100?????1010111")
# VMINU_VX           = Opcode("b000100???????????100?????1010111")
# VMIN_VX            = Opcode("b000101???????????100?????1010111")
# VMAXU_VX           = Opcode("b000110???????????100?????1010111")
# VMAX_VX            = Opcode("b000111???????????100?????1010111")
# VAND_VX            = Opcode("b001001???????????100?????1010111")
# VOR_VX             = Opcode("b001010???????????100?????1010111")
# VXOR_VX            = Opcode("b001011???????????100?????1010111")
# VRGATHER_VX        = Opcode("b001100???????????100?????1010111")
# VSLIDEUP_VX        = Opcode("b001110???????????100?????1010111")
# VSLIDEDOWN_VX      = Opcode("b001111???????????100?????1010111")
# VADC_VXM           = Opcode("b0100000??????????100?????1010111")
# VMADC_VXM          = Opcode("b010001???????????100?????1010111")
# VSBC_VXM           = Opcode("b0100100??????????100?????1010111")
# VMSBC_VXM          = Opcode("b010011???????????100?????1010111")
# VMERGE_VXM         = Opcode("b0101110??????????100?????1010111")
# VMV_V_X            = Opcode("b010111100000?????100?????1010111")
# VMSEQ_VX           = Opcode("b011000???????????100?????1010111")
# VMSNE_VX           = Opcode("b011001???????????100?????1010111")
# VMSLTU_VX          = Opcode("b011010???????????100?????1010111")
# VMSLT_VX           = Opcode("b011011???????????100?????1010111")
# VMSLEU_VX          = Opcode("b011100???????????100?????1010111")
# VMSLE_VX           = Opcode("b011101???????????100?????1010111")
# VMSGTU_VX          = Opcode("b011110???????????100?????1010111")
# VMSGT_VX           = Opcode("b011111???????????100?????1010111")
# VSADDU_VX          = Opcode("b100000???????????100?????1010111")
# VSADD_VX           = Opcode("b100001???????????100?????1010111")
# VSSUBU_VX          = Opcode("b100010???????????100?????1010111")
# VSSUB_VX           = Opcode("b100011???????????100?????1010111")
# VSLL_VX            = Opcode("b100101???????????100?????1010111")
# VSMUL_VX           = Opcode("b100111???????????100?????1010111")
# VSRL_VX            = Opcode("b101000???????????100?????1010111")
# VSRA_VX            = Opcode("b101001???????????100?????1010111")
# VSSRL_VX           = Opcode("b101010???????????100?????1010111")
# VSSRA_VX           = Opcode("b101011???????????100?????1010111")
# VNSRL_WX           = Opcode("b101100???????????100?????1010111")
# VNSRA_WX           = Opcode("b101101???????????100?????1010111")
# VNCLIPU_WX         = Opcode("b101110???????????100?????1010111")
# VNCLIP_WX          = Opcode("b101111???????????100?????1010111")
# VQMACCU_VX         = Opcode("b111100???????????100?????1010111")
# VQMACC_VX          = Opcode("b111101???????????100?????1010111")
# VQMACCUS_VX        = Opcode("b111110???????????100?????1010111")
# VQMACCSU_VX        = Opcode("b111111???????????100?????1010111")
# VADD_VV            = Opcode("b000000???????????000?????1010111")
# VSUB_VV            = Opcode("b000010???????????000?????1010111")
# VMINU_VV           = Opcode("b000100???????????000?????1010111")
# VMIN_VV            = Opcode("b000101???????????000?????1010111")
# VMAXU_VV           = Opcode("b000110???????????000?????1010111")
# VMAX_VV            = Opcode("b000111???????????000?????1010111")
# VAND_VV            = Opcode("b001001???????????000?????1010111")
# VOR_VV             = Opcode("b001010???????????000?????1010111")
# VXOR_VV            = Opcode("b001011???????????000?????1010111")
# VRGATHER_VV        = Opcode("b001100???????????000?????1010111")
# VRGATHEREI16_VV    = Opcode("b001110???????????000?????1010111")
# VADC_VVM           = Opcode("b0100000??????????000?????1010111")
# VMADC_VVM          = Opcode("b010001???????????000?????1010111")
# VSBC_VVM           = Opcode("b0100100??????????000?????1010111")
# VMSBC_VVM          = Opcode("b010011???????????000?????1010111")
# VMERGE_VVM         = Opcode("b0101110??????????000?????1010111")
# VMV_V_V            = Opcode("b010111100000?????000?????1010111")
# VMSEQ_VV           = Opcode("b011000???????????000?????1010111")
# VMSNE_VV           = Opcode("b011001???????????000?????1010111")
# VMSLTU_VV          = Opcode("b011010???????????000?????1010111")
# VMSLT_VV           = Opcode("b011011???????????000?????1010111")
# VMSLEU_VV          = Opcode("b011100???????????000?????1010111")
# VMSLE_VV           = Opcode("b011101???????????000?????1010111")
# VSADDU_VV          = Opcode("b100000???????????000?????1010111")
# VSADD_VV           = Opcode("b100001???????????000?????1010111")
# VSSUBU_VV          = Opcode("b100010???????????000?????1010111")
# VSSUB_VV           = Opcode("b100011???????????000?????1010111")
# VSLL_VV            = Opcode("b100101???????????000?????1010111")
# VSMUL_VV           = Opcode("b100111???????????000?????1010111")
# VSRL_VV            = Opcode("b101000???????????000?????1010111")
# VSRA_VV            = Opcode("b101001???????????000?????1010111")
# VSSRL_VV           = Opcode("b101010???????????000?????1010111")
# VSSRA_VV           = Opcode("b101011???????????000?????1010111")
# VNSRL_WV           = Opcode("b101100???????????000?????1010111")
# VNSRA_WV           = Opcode("b101101???????????000?????1010111")
# VNCLIPU_WV         = Opcode("b101110???????????000?????1010111")
# VNCLIP_WV          = Opcode("b101111???????????000?????1010111")
# VWREDSUMU_VS       = Opcode("b110000???????????000?????1010111")
# VWREDSUM_VS        = Opcode("b110001???????????000?????1010111")
# VDOTU_VV           = Opcode("b111000???????????000?????1010111")
# VDOT_VV            = Opcode("b111001???????????000?????1010111")
# VQMACCU_VV         = Opcode("b111100???????????000?????1010111")
# VQMACC_VV          = Opcode("b111101???????????000?????1010111")
# VQMACCSU_VV        = Opcode("b111111???????????000?????1010111")
# VADD_VI            = Opcode("b000000???????????011?????1010111")
# VRSUB_VI           = Opcode("b000011???????????011?????1010111")
# VAND_VI            = Opcode("b001001???????????011?????1010111")
# VOR_VI             = Opcode("b001010???????????011?????1010111")
# VXOR_VI            = Opcode("b001011???????????011?????1010111")
# VRGATHER_VI        = Opcode("b001100???????????011?????1010111")
# VSLIDEUP_VI        = Opcode("b001110???????????011?????1010111")
# VSLIDEDOWN_VI      = Opcode("b001111???????????011?????1010111")
# VADC_VIM           = Opcode("b0100000??????????011?????1010111")
# VMADC_VIM          = Opcode("b010001???????????011?????1010111")
# VMERGE_VIM         = Opcode("b0101110??????????011?????1010111")
# VMV_V_I            = Opcode("b010111100000?????011?????1010111")
# VMSEQ_VI           = Opcode("b011000???????????011?????1010111")
# VMSNE_VI           = Opcode("b011001???????????011?????1010111")
# VMSLEU_VI          = Opcode("b011100???????????011?????1010111")
# VMSLE_VI           = Opcode("b011101???????????011?????1010111")
# VMSGTU_VI          = Opcode("b011110???????????011?????1010111")
# VMSGT_VI           = Opcode("b011111???????????011?????1010111")
# VSADDU_VI          = Opcode("b100000???????????011?????1010111")
# VSADD_VI           = Opcode("b100001???????????011?????1010111")
# VSLL_VI            = Opcode("b100101???????????011?????1010111")
# VMV1R_V            = Opcode("b1001111?????00000011?????1010111")
# VMV2R_V            = Opcode("b1001111?????00001011?????1010111")
# VMV4R_V            = Opcode("b1001111?????00011011?????1010111")
# VMV8R_V            = Opcode("b1001111?????00111011?????1010111")
# VSRL_VI            = Opcode("b101000???????????011?????1010111")
# VSRA_VI            = Opcode("b101001???????????011?????1010111")
# VSSRL_VI           = Opcode("b101010???????????011?????1010111")
# VSSRA_VI           = Opcode("b101011???????????011?????1010111")
# VNSRL_WI           = Opcode("b101100???????????011?????1010111")
# VNSRA_WI           = Opcode("b101101???????????011?????1010111")
# VNCLIPU_WI         = Opcode("b101110???????????011?????1010111")
# VNCLIP_WI          = Opcode("b101111???????????011?????1010111")
# VREDSUM_VS         = Opcode("b000000???????????010?????1010111")
# VREDAND_VS         = Opcode("b000001???????????010?????1010111")
# VREDOR_VS          = Opcode("b000010???????????010?????1010111")
# VREDXOR_VS         = Opcode("b000011???????????010?????1010111")
# VREDMINU_VS        = Opcode("b000100???????????010?????1010111")
# VREDMIN_VS         = Opcode("b000101???????????010?????1010111")
# VREDMAXU_VS        = Opcode("b000110???????????010?????1010111")
# VREDMAX_VS         = Opcode("b000111???????????010?????1010111")
# VAADDU_VV          = Opcode("b001000???????????010?????1010111")
# VAADD_VV           = Opcode("b001001???????????010?????1010111")
# VASUBU_VV          = Opcode("b001010???????????010?????1010111")
# VASUB_VV           = Opcode("b001011???????????010?????1010111")
# VMV_X_S            = Opcode("b0100001?????00000010?????1010111")
# VZEXT_VF8          = Opcode("b010010??????00010010?????1010111")
# VSEXT_VF8          = Opcode("b010010??????00011010?????1010111")
# VZEXT_VF4          = Opcode("b010010??????00100010?????1010111")
# VSEXT_VF4          = Opcode("b010010??????00101010?????1010111")
# VZEXT_VF2          = Opcode("b010010??????00110010?????1010111")
# VSEXT_VF2          = Opcode("b010010??????00111010?????1010111")
# VCOMPRESS_VM       = Opcode("b0101111??????????010?????1010111")
# VMANDNOT_MM        = Opcode("b011000???????????010?????1010111")
# VMAND_MM           = Opcode("b011001???????????010?????1010111")
# VMOR_MM            = Opcode("b011010???????????010?????1010111")
# VMXOR_MM           = Opcode("b011011???????????010?????1010111")
# VMORNOT_MM         = Opcode("b011100???????????010?????1010111")
# VMNAND_MM          = Opcode("b011101???????????010?????1010111")
# VMNOR_MM           = Opcode("b011110???????????010?????1010111")
# VMXNOR_MM          = Opcode("b011111???????????010?????1010111")
# VMSBF_M            = Opcode("b010100??????00001010?????1010111")
# VMSOF_M            = Opcode("b010100??????00010010?????1010111")
# VMSIF_M            = Opcode("b010100??????00011010?????1010111")
# VIOTA_M            = Opcode("b010100??????10000010?????1010111")
# VID_V              = Opcode("b010100?0000010001010?????1010111")
# VPOPC_M            = Opcode("b010000??????10000010?????1010111")
# VFIRST_M           = Opcode("b010000??????10001010?????1010111")
# VDIVU_VV           = Opcode("b100000???????????010?????1010111")
# VDIV_VV            = Opcode("b100001???????????010?????1010111")
# VREMU_VV           = Opcode("b100010???????????010?????1010111")
# VREM_VV            = Opcode("b100011???????????010?????1010111")
# VMULHU_VV          = Opcode("b100100???????????010?????1010111")
# VMUL_VV            = Opcode("b100101???????????010?????1010111")
# VMULHSU_VV         = Opcode("b100110???????????010?????1010111")
# VMULH_VV           = Opcode("b100111???????????010?????1010111")
# VMADD_VV           = Opcode("b101001???????????010?????1010111")
# VNMSUB_VV          = Opcode("b101011???????????010?????1010111")
# VMACC_VV           = Opcode("b101101???????????010?????1010111")
# VNMSAC_VV          = Opcode("b101111???????????010?????1010111")
# VWADDU_VV          = Opcode("b110000???????????010?????1010111")
# VWADD_VV           = Opcode("b110001???????????010?????1010111")
# VWSUBU_VV          = Opcode("b110010???????????010?????1010111")
# VWSUB_VV           = Opcode("b110011???????????010?????1010111")
# VWADDU_WV          = Opcode("b110100???????????010?????1010111")
# VWADD_WV           = Opcode("b110101???????????010?????1010111")
# VWSUBU_WV          = Opcode("b110110???????????010?????1010111")
# VWSUB_WV           = Opcode("b110111???????????010?????1010111")
# VWMULU_VV          = Opcode("b111000???????????010?????1010111")
# VWMULSU_VV         = Opcode("b111010???????????010?????1010111")
# VWMUL_VV           = Opcode("b111011???????????010?????1010111")
# VWMACCU_VV         = Opcode("b111100???????????010?????1010111")
# VWMACC_VV          = Opcode("b111101???????????010?????1010111")
# VWMACCSU_VV        = Opcode("b111111???????????010?????1010111")
# VAADDU_VX          = Opcode("b001000???????????110?????1010111")
# VAADD_VX           = Opcode("b001001???????????110?????1010111")
# VASUBU_VX          = Opcode("b001010???????????110?????1010111")
# VASUB_VX           = Opcode("b001011???????????110?????1010111")
# VMV_S_X            = Opcode("b010000100000?????110?????1010111")
# VSLIDE1UP_VX       = Opcode("b001110???????????110?????1010111")
# VSLIDE1DOWN_VX     = Opcode("b001111???????????110?????1010111")
# VDIVU_VX           = Opcode("b100000???????????110?????1010111")
# VDIV_VX            = Opcode("b100001???????????110?????1010111")
# VREMU_VX           = Opcode("b100010???????????110?????1010111")
# VREM_VX            = Opcode("b100011???????????110?????1010111")
# VMULHU_VX          = Opcode("b100100???????????110?????1010111")
# VMUL_VX            = Opcode("b100101???????????110?????1010111")
# VMULHSU_VX         = Opcode("b100110???????????110?????1010111")
# VMULH_VX           = Opcode("b100111???????????110?????1010111")
# VMADD_VX           = Opcode("b101001???????????110?????1010111")
# VNMSUB_VX          = Opcode("b101011???????????110?????1010111")
# VMACC_VX           = Opcode("b101101???????????110?????1010111")
# VNMSAC_VX          = Opcode("b101111???????????110?????1010111")
# VWADDU_VX          = Opcode("b110000???????????110?????1010111")
# VWADD_VX           = Opcode("b110001???????????110?????1010111")
# VWSUBU_VX          = Opcode("b110010???????????110?????1010111")
# VWSUB_VX           = Opcode("b110011???????????110?????1010111")
# VWADDU_WX          = Opcode("b110100???????????110?????1010111")
# VWADD_WX           = Opcode("b110101???????????110?????1010111")
# VWSUBU_WX          = Opcode("b110110???????????110?????1010111")
# VWSUB_WX           = Opcode("b110111???????????110?????1010111")
# VWMULU_VX          = Opcode("b111000???????????110?????1010111")
# VWMULSU_VX         = Opcode("b111010???????????110?????1010111")
# VWMUL_VX           = Opcode("b111011???????????110?????1010111")
# VWMACCU_VX         = Opcode("b111100???????????110?????1010111")
# VWMACC_VX          = Opcode("b111101???????????110?????1010111")
# VWMACCUS_VX        = Opcode("b111110???????????110?????1010111")
# VWMACCSU_VX        = Opcode("b111111???????????110?????1010111")
# VAMOSWAPEI8_V      = Opcode("b00001????????????000?????0101111")
# VAMOADDEI8_V       = Opcode("b00000????????????000?????0101111")
# VAMOXOREI8_V       = Opcode("b00100????????????000?????0101111")
# VAMOANDEI8_V       = Opcode("b01100????????????000?????0101111")
# VAMOOREI8_V        = Opcode("b01000????????????000?????0101111")
# VAMOMINEI8_V       = Opcode("b10000????????????000?????0101111")
# VAMOMAXEI8_V       = Opcode("b10100????????????000?????0101111")
# VAMOMINUEI8_V      = Opcode("b11000????????????000?????0101111")
# VAMOMAXUEI8_V      = Opcode("b11100????????????000?????0101111")
# VAMOSWAPEI16_V     = Opcode("b00001????????????101?????0101111")
# VAMOADDEI16_V      = Opcode("b00000????????????101?????0101111")
# VAMOXOREI16_V      = Opcode("b00100????????????101?????0101111")
# VAMOANDEI16_V      = Opcode("b01100????????????101?????0101111")
# VAMOOREI16_V       = Opcode("b01000????????????101?????0101111")
# VAMOMINEI16_V      = Opcode("b10000????????????101?????0101111")
# VAMOMAXEI16_V      = Opcode("b10100????????????101?????0101111")
# VAMOMINUEI16_V     = Opcode("b11000????????????101?????0101111")
# VAMOMAXUEI16_V     = Opcode("b11100????????????101?????0101111")
# VAMOSWAPEI32_V     = Opcode("b00001????????????110?????0101111")
# VAMOADDEI32_V      = Opcode("b00000????????????110?????0101111")
# VAMOXOREI32_V      = Opcode("b00100????????????110?????0101111")
# VAMOANDEI32_V      = Opcode("b01100????????????110?????0101111")
# VAMOOREI32_V       = Opcode("b01000????????????110?????0101111")
# VAMOMINEI32_V      = Opcode("b10000????????????110?????0101111")
# VAMOMAXEI32_V      = Opcode("b10100????????????110?????0101111")
# VAMOMINUEI32_V     = Opcode("b11000????????????110?????0101111")
# VAMOMAXUEI32_V     = Opcode("b11100????????????110?????0101111")
# VAMOSWAPEI64_V     = Opcode("b00001????????????111?????0101111")
# VAMOADDEI64_V      = Opcode("b00000????????????111?????0101111")
# VAMOXOREI64_V      = Opcode("b00100????????????111?????0101111")
# VAMOANDEI64_V      = Opcode("b01100????????????111?????0101111")
# VAMOOREI64_V       = Opcode("b01000????????????111?????0101111")
# VAMOMINEI64_V      = Opcode("b10000????????????111?????0101111")
# VAMOMAXEI64_V      = Opcode("b10100????????????111?????0101111")
# VAMOMINUEI64_V     = Opcode("b11000????????????111?????0101111")
# VAMOMAXUEI64_V     = Opcode("b11100????????????111?????0101111")
# VMVNFR_V           = Opcode("b1001111??????????011?????1010111")
SLLI_RV32          = Opcode("b0000000??????????001?????0010011")
SRLI_RV32          = Opcode("b0000000??????????101?????0010011")
SRAI_RV32          = Opcode("b0100000??????????101?????0010011")
RORI_RV32          = Opcode("b0110000??????????101?????0010011")
# FRFLAGS            = Opcode("b00000000000100000010?????1110011")
# FSFLAGS            = Opcode("b000000000001?????001?????1110011")
# FSFLAGSI           = Opcode("b000000000001?????101?????1110011")
# FRRM               = Opcode("b00000000001000000010?????1110011")
# FSRM               = Opcode("b000000000010?????001?????1110011")
# FSRMI              = Opcode("b000000000010?????101?????1110011")
# FSCSR              = Opcode("b000000000011?????001?????1110011")
# FRCSR              = Opcode("b00000000001100000010?????1110011")
# RDCYCLE            = Opcode("b11000000000000000010?????1110011")
# RDTIME             = Opcode("b11000000000100000010?????1110011")
# RDINSTRET          = Opcode("b11000000001000000010?????1110011")
# RDCYCLEH           = Opcode("b11001000000000000010?????1110011")
# RDTIMEH            = Opcode("b11001000000100000010?????1110011")
# RDINSTRETH         = Opcode("b11001000001000000010?????1110011")
# SCALL              = Opcode("b00000000000000000000000001110011")
# SBREAK             = Opcode("b00000000000100000000000001110011")
# FMV_X_S            = Opcode("b111000000000?????000?????1010011")
# FMV_S_X            = Opcode("b111100000000?????000?????1010011")
# FENCE_TSO          = Opcode("b100000110011?????000?????0001111")
# PAUSE              = Opcode("b00000001000000000000000000001111")


BR_OPCODES = {BEQ, BNE, BLT, BGE, BLTU}
JAL_OPCODES = {JALR, JAL}
BRJAL_OPCODES = BR_OPCODES | JAL_OPCODES
LD_OPCODES = {LB, LH, LW, LD, LBU, LHU, LWU}
ST_OPCODES = {SB, SH, SW, SD}
LDST_OPCODES = LD_OPCODES | ST_OPCODES
ARITH_OPCODES = {LUI, AUIPC, ADDI, SLLI, SLTI, SLTIU, XORI, SRLI, SRAI, ORI, ANDI,
                 ADD, SUB, SLL, SLT, SLTU, XOR, SRL, SRA, OR, AND,
                 ADDIW, SLLIW, SRLIW, SRAIW,
                 ADDW, SUBW, SLLW, SRLW, SRAW,
                 MUL, MULH, MULHSU, MULHU, DIV, DIVU,
                 REM, REMU, MULW, DIVW, DIVUW, REMW, REMUW,
                 SLLI_RV32, SRLI_RV32, SRAI_RV32, RORI_RV32
                 }
